package DAO;

import java.io.*;
import java.util.*;
import org.hibernate.Query;

/**
 * GenericDAO interface, contains CRUD operations
 * and some queries to get all, or some specific type of entity
 * 
 * @param <T> - an entity class 
 * @param <ID> - id class which is used to describes id's of entities.
 */
public interface GenericDAO <T, ID> {
	
	/**
	 * Saves or updates given entity to the DB
	 */
	public void save(T entity);
	
	/**
	 * Merges given entity to the DB
	 */
	public void merge(T entity);
	
	/**
	 * Delete given entity from the DB
	 */
	public void delete(T entity);
	
	/**
	 * Find all entities of the given type class type in the DB
	 */
	public List<T> findAll(Class<? extends Serializable> clazz);
	
	/**
	 * Find many entities according to the query in the DB
	 */
	public List<T> findMany(Query query);
	
	/**
	 * Find one entity according to the query in the DB
	 */
	public T findOne(Query query);
	
	/**
	 * Find one entity according to the given ID and class type in the DB
	 */
	public T findByID(Class<? extends Serializable> clazz, Integer id);
}